package leetcode;

public class Test1299 {
    public int[] replaceElements(int[] arr) {
        int max=Integer.MIN_VALUE;
        for(int i=arr.length-1;i>=0;i++){
            if(arr[i]>max)
                max=arr[i];
            if(i== arr.length-1){
                arr[i]=-1;
            }
            else {
                arr[i]=max;
            }
        }
        return arr;
    }
}
